<?php

use yii\helpers\Html;
use mdm\admin\components\Helper;
use yii\grid\GridView;
use \common\helpers\TStringHelper;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('common', 'themes');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="themes-index">

    <?php
    if(Helper::checkRoute('create')) {
    ?>
    <p>
        <?= Html::a(Yii::t('common', 'create_{modelClass}', ['modelClass' => Yii::t('common', 'themes')]), ['create'], ['class' => 'btn btn-success']) ?>
    </p>
    <?php
    }
    ?>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
            //['class' => 'yii\grid\SerialColumn'],

            'id',
            'name',
            'template_key',
            [
                'attribute' => 'status',
                'value' => function($model){
                    return TStringHelper::getStatusText($model->status);
                }
            ],
            [
                'attribute' => 'created_at',
                'value' => function($model){
                    return TStringHelper::ShowDate($model->created_at, 1);
                }
            ],
            //'version',
            // 'created_by',
            // 'created_at',
            // 'created_from',
            // 'created_ip',
            // 'updated_by',
            // 'updated_at',
            // 'updated_from',
            // 'updated_ip',
            // 'is_deleted',

            [
                'class' => 'yii\grid\ActionColumn',
                'header' => Yii::t('common', 'operation_button'),
                'template' => '{updatepop}{deleteButton}',
                'buttons' => [
                    'updatepop' => function ($url, $model, $key) {
                        if ($model->template_key != 'basic') {
                            return Html::a('<span class="glyphicon glyphicon-pencil"></span>', Yii::$app->urlManager->createUrl(['themes/update', 'id' => $model->id]), ['class' => 'EditButton', 'title' => Yii::t('common', 'edit_button')]);
                        }

                    },
                    'deleteButton' => function ($url, $model, $key) {
                        if ($model->template_key != 'basic') {
                            return Html::a('<span class="glyphicon glyphicon-trash"></span>', '#', ['class' => 'DeleteButton', 'title' => Yii::t('common', 'delete_button'), 'onclick' => 'deleteButton("formModal", "' . $model->id . '","' . Yii::$app->urlManager->createUrl(['themes/delete', 'id' => $model->id]) . '");']);
                        }
                    },
                ],
            ],
        ],
    ]); ?>
</div>
